<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>vrandi</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="vrandh.html" title="vrandh" />
    <link rel="next" href="vstaudio.html" title="vstaudio, vstaudiog" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">vrandi</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="vrandh.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="vstaudio.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="vrandi"></a>
      <div class="titlepage"></div>
      <a id="IndexVrandi" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">vrandi</span>
        </h2>
        <p>vrandi — 
      Generate a sort of 'vectorial band-limited noise'
    </p>
      </div>
      <div class="refsect1">
        <a id="idp166099136"></a>
        <h2>Description</h2>
        <p>
      Generate a sort of 'vectorial band-limited noise'
    </p>
      </div>
      <div class="refsect1">
        <a id="idp166100288"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>vrandi</strong></span>  ifn,  krange, kcps, ielements [, idstoffset] [, iseed] \
      [, isize] [, ioffset]</pre>
      </div>
      <div class="refsect1">
        <a id="idp166102272"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifn</em></span> - number of the table where the vectorial signal will be generated
    </p>
        <p>
      <span class="emphasis"><em>ielements</em></span> - number of elements to process
    </p>
        <p>
      <span class="emphasis"><em>idstoffset</em></span> - (optional, default=0) -- index offset for the destination table
    </p>
        <p>
      <span class="emphasis"><em>iseed</em></span> (optional, default=0.5) -- seed value for the recursive pseudo-random formula. A value between 0 and +1 will produce an initial output of <span class="emphasis"><em>kamp</em></span> * <span class="emphasis"><em>iseed</em></span>. A negative value will cause seed re-initialization to be skipped. A value greater than 1 will seed from system time, this is the best option to generate a different random sequence for each run.
    </p>
        <p>
      <span class="emphasis"><em>isize</em></span> (optional, default=0) -- if zero, a 16 bit number is generated. If non-zero, a 31-bit random number is generated. Default is 0.
    </p>
        <p>
      <span class="emphasis"><em>ioffset</em></span> - (optional, default=0) -- a base value added to the random result.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp166109456"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>krange</em></span> - range of random elements (from -<span class="emphasis"><em>krange</em></span> to <span class="emphasis"><em>krange</em></span>)
    </p>
        <p>
      <span class="emphasis"><em>kcps</em></span> - rate of generated elements in cycles per seconds
    </p>
        <p>
      This opcode is similar to <a class="link" href="randi.html" title="randi"><em class="citetitle">randi</em></a>, but operates on vectors instead of with scalar values.
    </p>
        <p>
      Though argument <span class="emphasis"><em>isize</em></span> defaults to 0, thus using a 16-bit random number generator, using the newer 31-bit algorithm is recommended, as this will produce a random sequence with a longer period (more random numbers before the sequence starts repeating).
    </p>
        <p>
      The output is a vector contained in <span class="emphasis"><em>ifn</em></span> (that must be previously allocated).
    </p>
        <p>
      All these operators are designed to be used together with other opcodes that operate with vector such as <a class="link" href="adsynt.html" title="adsynt"><em class="citetitle">adsynt</em></a>, etc.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp166118608"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the vrandi opcode. It uses the file <a class="ulink" href="examples/vrandi.csd" target="_top"><em class="citetitle">vrandi.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp166120432"></a>
          <p class="title">
            <strong>Example 1020. Example of the vrandi opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o vrandi.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span><span class="op">=</span>44100
<span class="ohdr">ksmps</span><span class="op">=</span>128
<span class="ohdr">nchnls</span><span class="op">=</span>2

<span class="comment">;Example by Andres Cabrera</span>

gitab <span class="ohdr">ftgen</span> 0, 0, 16, <span class="op">-</span>7, 0, 128, 0

<span class="oblock">instr</span> 1
  krange <span class="opc">init</span> p4
  kcps <span class="opc">init</span> p5
  ioffset <span class="opc">init</span> p6
  <span class="comment">;       table   krange  kcps  ielements   idstoffset  iseed  isize ioffset</span>
  <span class="opc">vrandi</span>  gitab,  krange, kcps,     3,         3,         2,   1,    ioffset

  kfreq1 <span class="opc">table</span> 3, gitab
  kfreq2 <span class="opc">table</span> 4, gitab
  kfreq3 <span class="opc">table</span> 5, gitab

  <span class="comment">;Change the frequency of three oscillators according to the random values</span>
  aosc1 <span class="opc">oscili</span> 4000, kfreq1, 1
  aosc2 <span class="opc">oscili</span> 2000, kfreq2, 1
  aosc3 <span class="opc">oscili</span> 4000, kfreq3, 1

  <span class="opc">outs</span> aosc1<span class="op">+</span>aosc2, aosc3<span class="op">+</span>aosc2
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">f</span> 1 0 2048 10 1

<span class="comment">;             krange  kcps    ioffset</span>
<span class="stamnt">i</span> 1 0 	5	100	1	300
<span class="stamnt">i</span> 1 5 	5	5	1	400
<span class="stamnt">i</span> 1 10 	5	100	2	1000
<span class="stamnt">i</span> 1 15 	5	400	4	1000
<span class="stamnt">i</span> 1 20 	5	1000	8	2000
<span class="stamnt">i</span> 1 20 	5	300	32	350
  
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp166124624"></a>
        <h2>See also</h2>
        <p>
      <a class="link" href="vrandh.html" title="vrandh"><em class="citetitle">vrandh</em></a>, 
      <a class="link" href="randi.html" title="randi"><em class="citetitle">randi</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp166127632"></a>
        <h2>Credits</h2>
        <p>Written by Gabriel Maldonado.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="vrandh.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="vstaudio.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">vrandh </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> vstaudio, vstaudiog</td>
        </tr>
      </table>
    </div>
  </body>
</html>
